// "single_application.h"

#ifndef SINGLE_APPLICATION_H
#define SINGLE_APPLICATION_H

#include <QApplication>
#include <QSharedMemory>
#include <QLocalServer>
#include <QWindow>
class SingleApplication : public QApplication

{
    Q_OBJECT
public:

    SingleApplication(int &argc, char *argv[], const QString uniqueKey);
    bool isRunning();
    bool sendMessage(const QString &message);
    void set_run_widget(QWindow* widget);
private:
    virtual bool notify(QObject *obj, QEvent *event);
public slots:
    void receiveMessage();
    void activeRunWindow();
signals:
    void messageAvailable(QString message);
private:
    bool _isRunning;
    QString _uniqueKey;
    QSharedMemory sharedMemory;
    QLocalServer *localServer;
    static const int timeout = 1000;
    QWindow*			_run_widget = nullptr;
};

#endif // SINGLE_APPLICATION_H
